package com.yuntian.mapper;

import com.github.pagehelper.Page;
import com.yuntian.Dto.ProductPageQueryDto;
import com.yuntian.entity.Product;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;


@Mapper
public interface ProductMapper {
    Page<Product> selectList(ProductPageQueryDto productPageQueryDto);

    void insertProduct(Product product);

    void updateProduct(Product product);

    void deleteProduct(Integer productId);


    @Select("SELECT product.quantity FROM product WHERE product_id = #{productId} ")
    Integer selectProductQuantity(Integer productId);

    BigDecimal getProductPrice(Integer productId);

    @Update("UPDATE product SET quantity = #{quantity} WHERE product_id = #{productId}")
    void updateProductPrice( Integer quantity,Integer productId);

    @Select("SELECT * FROM product WHERE product_name = #{productName}")
    Product selectByName(String productName);
}
